package com.example.controller;

import com.example.pojo.PageBean;
import com.example.pojo.Supplier;
import com.example.tools.Result;
import com.example.pojo.Brand;
import com.example.service.impl.BrandServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/admin")
public class BrandController {

    @Autowired
    private BrandServiceImpl brandService;

    /**
     * 获取品牌信息
     * @return
     */
    @PostMapping("/getBrand")
    public Result getBrand(
        @RequestBody Brand brand,
        @RequestParam(defaultValue = "1") Integer page,
        @RequestParam(defaultValue = "10") Integer pageSize) {

            //log.info("supplier：{}",supplier);
            PageBean pageBean = brandService.getBrand(brand,page, pageSize);
            //log.info("查询全部教徒数据,deptlist:{}",pageBean);
            return Result.success(pageBean);
    }
    @GetMapping ("/getBrandList")
    public Result getBrandList() {
        List<Brand> brandList = brandService.getBrandList();
        return Result.success(brandList);
    }

    /**
     * 修改品牌信息
     */
    @PostMapping("/changeBrand")
    public Result changeBrand(@RequestBody Brand brand){
        brandService.changeBrand(brand);
        return Result.success();
    }

    /**
     * 删除品牌
     * @param id
     * @return
     */
    @DeleteMapping("/deleteBrand")
    public Result deleteBrand(String id){
        brandService.deleteBrand(id);
        return Result.success();
    }

    /**
     * 添加品牌信息
     * @param brand
     * @return
     */

    @PostMapping("/addBrand")
    public Result addBrand(@RequestBody Brand brand){
        brandService.addBrand(brand);
        return Result.success();
    }


}
